/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.td.engine.combat;

import org.td.engine.combat.effect.Effect;
import org.td.engine.combat.effect.LaunchProjectileEffect;
import org.td.engine.entity.ParameterMap;
import org.td.engine.entity.ProjectileClass;

import java.util.Random;

public class WeaponClass {
    
    private float cooldown;
    private float range;
    private Effect attackEffect;
    
    public WeaponClass(ParameterMap parameterMap) {
        cooldown = parameterMap.getValue("cooldown", Float.class);
        range = parameterMap.getValue("range", Float.class);
        attackEffect = parameterMap.getValue("attackEffect", Effect.class);
    }
    
    public float getCooldown() {
        return cooldown;
    }
    
    public float getRange() {
        return range;
    }

    public Effect getAttackEffect() {
        return attackEffect;
    }

    public static WeaponClass getRandom() {
        Random rnd = new Random();
        ParameterMap parameterMap = new ParameterMap();
        parameterMap.putValue("cooldown", rnd.nextInt(20) / 10f + 0.4f);
        parameterMap.putValue("range", (100f + rnd.nextInt(100)));
            ParameterMap paramMap2 = new ParameterMap();
            paramMap2.putValue("assetFile", "faces/8");
            parameterMap.putValue("attackEffect", new LaunchProjectileEffect(new ProjectileClass(paramMap2)));
        return new WeaponClass(parameterMap);
    }
}
